<template>
    <div class="bgimgcompany">
        <div class="login2" >
               <div>
                   <h3>企业登录</h3>
                   <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm">
                       <el-form-item prop="compname"  el-icon="el-icon-user">
                           <el-input placeholder="用户名" v-model="ruleForm.compname" style="width: 300px"></el-input>
                       </el-form-item>
                       <el-form-item prop="comppass" >
                           <el-input placeholder="密码" type="password" v-model="ruleForm.comppass"
                                     autocomplete="off" style="width: 300px"></el-input>
                       </el-form-item>
                       <el-form-item >
                               <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
                               <el-button @click="resetForm('ruleForm')">重置</el-button>
                       </el-form-item>
                   </el-form>
               </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'login',

        data() {
            return {
                activeIndex: '1',
                ruleForm: {
                    compname: '',
                    comppass: '',

                },
                rules: {
                    compname: [
                        {required: true, message: '请输入用户名', trigger: 'blur'},
                        {min: 6, max: 12, message: '长度在 6 到 12 个字符', trigger: 'blur'}
                    ],
                    comppass: [
                        {required: true, message: '请输入密码', trigger: 'blur'},
                        {min: 6, max: 12, message: '长度在 6 到 12 个字符', trigger: 'blur'}
                    ],
                }
            }
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            },
            goBack() {
                this.$router.go(-1);
            }
        }
    }
</script>
<style scoped>
    .login2 {
        display: flex;
        flex-direction: row;
        justify-content: center;
        background: #fff;
        border: 1px solid #ededed;
        margin-left: 55%;
        margin-top: 5%;
        width: 500px;
        box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        position: relative;
    }
</style>
